<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue-router</title>
  </head>
  <body>
    <pre>
        使用静态资源的props，进行动态分配
        props: { name: 'hhhha', age: '100' },props为一个对象
        标签中接收props接收指定的数据名
    </pre>
    <div id="app">
      <router-link to="/login">登录</router-link>
      <router-link to="/register">注册</router-link>
      <router-link to="/test/1">test</router-link>
      <router-link to="/test/sffds">test</router-link>
      <router-link to="/test/3">test</router-link>
      <router-link to="/test/4">test</router-link>
      <router-link to="/test/5">test</router-link>
      <router-view></router-view>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script src="../node_modules/vue-router/dist/vue-router.js"></script>
    <script>
      const login = {
        template: `
        <div>
          <h1>login</h1>
          <h1>login</h1>
        </div>
          `,
      }
      const regiest = {
        template: `
        <div>
          <h1>regiest</h1>
          <h1>login</h1>
        </div>
          `,
      }

      const children1 = {
        props: ['name', 'age'],
        template: `
          <h1>children1 {{name}}{{age}}</h1>
          `,
      }
      const routers = new VueRouter({
        routes: [
          { path: '/', redirect: '/register' },
          { path: '/login', component: login },
          { path: '/register', component: regiest },
          {
            path: '/test/:id',
            component: children1,
            props: { name: 'hhhha', age: '100' },
          },
        ],
      })
      const vm = new Vue({
        el: '#app',
        data: {},
        router: routers,
      })
    </script>
  </body>
</html>
